# reproduce `log_sum_exp`functionlog_sum_exp(x) xmax =maximum(x) xsum =sum( exp.( x .- xmax ) ) xmax +log(xsum)endfunctioncompute_logPrW(W, H, a, b, sigma, prior=1) mu = a .+ b .* Hsum(logpdf.(Normal.(mu, sigma), W)) +log(prior)endfunctioncompute_post(W, H, a, b, sigma, prior=1) G = [[a, b[j], sigma] for j in1:length(b)]# Compute probability of each post = [compute_logPrW(W, H, G[i][1], G[i][2], G[i][3], 1) for i in1:length(G)] post =exp.(post .-log_sum_exp(post))# SOURCE# https://discourse.julialang.org/t/how-to-convert-vector-of-vectors-to-matrix/72609/27 mat =hcat(stack(G, dims=1), post)NamedArray(round.(mat', digits=3), (["a", "b", "sigma", "post"], 1:length(beta_seq)), ("vars","elem"))end